package com.ys.utils.redis.key;

import com.ys.utils.base.j2se.DateUtil;

/**
 * Description
 * Created by 王伟
 * Date create on 16:06 2019/11/21.
 */
public class UserKey {

    /* 根据 微信unionId 获取用户缓存 uid */
    public static String uidByUnion(Object unionId) {
        return String.format("user:unionId:%s", unionId);
    }

    /* 根据 token 获取用户缓存 uid */
    public static String uidByToken(Object token) {
        return String.format("user:token:%s", token);
    }
    public static String uidByToken(long uid) {
        return String.format("user:id:token:%s", uid);
    }
    /* 根据 phone 获取用户缓存 uid */
    public static String uidByPhone(Object phone) {
        return String.format("user:phone:%s", phone);
    }

    /* 根据 phone 获取用户缓存 uid */
    public static String uidByApple(Object appleId) {
        return String.format("user:apple:%s", appleId);
    }

    /* 根据 uid 获取用户缓存 userinfo */
    public static String userInfoByUid(Object uid) {
        return String.format("user:info:%s", uid);
    }

    /* 根据 uid 获取用户缓存 userinfo */
    public static String userLoginTimeByUid() {
        return "user:login:time";
    }

    /* 根据 phone 获取验证码  code */
    public static String codeByPhone(Object phone) {
        return String.format("user:sms:%s", phone);
    }

    /**
     * 好友列表 key
     *
     * @param uid 用户id
     * @return
     */
    public static String getUserFriendsListKey(Object uid) {
        return String.format("user:friends:%s", uid);
    }

    /**
     * 没有好友列表的标志 key
     *
     * @param uid
     * @return
     */
    public static String getNoListFlag(String uid) {
        return String.format("user:no:friends:%s", uid);
    }

    /**
     * 好友申请列表
     *
     * @param uid
     * @return
     */
    public static String getUserApplyKey(Object uid) {
        return String.format("user:friends:apply:%s", uid);
    }

    /**
     * 获取用户需要存入数据库中的 list
     *
     * @return
     */
    public static String getUserInsertListKey() {
        return String.format("user:message:insert");
    }

    /**
     * 获取用户关联的组信息
     *
     * @param uid
     * @return
     */
    public static String groupInfoKey(Object uid) {
        return String.format("user:group:%s", uid);
    }

    public static String noticeKey(Object uid) {
        return String.format("user:notice:%s", uid);
    }

    /**
     * 获取用户禁言时间key
     *
     * @param uid
     * @return
     */
    public static String getUserBannedTimeKey(Object uid) {
        return String.format("user:banned:%s", uid);
    }

    /**
     * 用户群聊更新数据集合的缓存key
     *
     * @param uid
     * @return
     */
    public static String groupChatUpdateCacheKey(Long uid) {
        return String.format("user:chat:%s", uid);
    }

    /**
     * 用户终端
     *
     * @return
     */
    public static String terminalHash() {
        return "user:terminal";
    }

    //用户隐私设置缓存key
    public static String getPrivacyConfigKey(long uid) {
        return String.format("user:privacy:config:%s", uid);
    }

    /**
     * 通知清理群消息
     *
     * @param uid
     * @return
     */
    public static String messageClearKey(Object uid) {
        return String.format("user:message:clear:%s", uid);
    }

    public static String rechargeCreateKey(Object dayKey, Object uid) {
        return String.format("wallet:recharge:%s:%s", dayKey, uid);
    }

    public static String rechargeCreateZFBMoneyAllKey(Object dayKey, Object uid) {
        return String.format("wallet:recharge:all:zfb:%s:%s", dayKey, uid);
    }

    public static String rechargeCreateMoneyAllKey(Object dayKey, Object uid) {
        return String.format("wallet:recharge:all:%s:%s", dayKey, uid);
    }

    public static String rechargeFreeDayKey(Object dayKey) {
        return String.format("wallet:recharge:day:free:%s", dayKey);
    }
    public static String withholdingCreateKey(Object dayKey, Object uid) {
        return String.format("wallet:withholding:create:%s:%s", dayKey, uid);
    }

    public static String withholdingFreeKey(Object dayKey, Object uid) {
        return String.format("wallet:withholding:free:%s:%s", dayKey, uid);
    }
    public static String withholdingHjzfFreeDayKey(Object dayKey) {
        return String.format("wallet:withholding:day:hjzf:free:%s", dayKey);
    }
    public static String withholdingFreeDayKey(Object dayKey) {
        return String.format("wallet:withholding:day:free:%s", dayKey);
    }
    public static String addFriendKey(Object sum) {
        return String.format("user:addFriend:lock:%s", sum);
    }

    public static String lockMessage(Object uid) {
        return String.format("user:message:lock:%s", uid);
    }

    public static String connectTimeKey() {
        return "user:connect:time";
    }

    public static String unReadMessageKey(Object mCode){return String.format("user:unread:count:%s",mCode);}

    public static String unReadKey(Long uid) {
        return String.format("user:unread:ack:%s", uid);
    }

    public static String userUnReadMessageEntityKey(Object uid) {
        return String.format("user:unread:entity:%s", uid);
    }

    public static String smsCountByDay(Object phone) {
        return String.format("user:sms:count:%s:%s", DateUtil.getYYMMDD(), phone);
    }

    public static String withholdingCreateKeyLimit(Object uid) {
        return String.format("wallet:withholding:limit:%s", uid);
    }

    public static String jPushRelationIdKey() {
        return String.format("user:relationId");
    }

    public static String displayWalletUidKey(){return "display.wallet.uid";}

    public static String forgetPasswordByIp(String ip){return String.format("user:forgetPassword:%s:%s", DateUtil.getYYMMDD(),ip);}

    public static String rechargeHjzfCreateKey(int dayKey, String uid) {
        return String.format("wallet:recharge:hjzf:%s:%s", dayKey, uid);
    }

    public static String rechargeCreateHjzfMoneyAllKey(int dayKey, String uid) {
        return String.format("wallet:recharge:all:hjzf:%s:%s", dayKey, uid);
    }

    public static String rechargeFreeHjzfDayKey(int dayKey) {
        return String.format("wallet:recharge:hjzf:day:free:%s", dayKey);
    }

    public static String rechargeCreatehHzfMoneyAllKey(int dayKey, int uid) {
        return String.format("wallet:recharge:all:hjzf:%s:%s", dayKey, uid);

    }
}
